package com.tataben.db;

import android.util.Log;

/**
 * 日志
 * Created by dlilang on 2017/8/7 0007.
 */
public class DLLogger {

    private DLLogger() {}

    private static String generateTag() {
        StackTraceElement caller = new Throwable().getStackTrace()[2];

        String tag = "MMJ %s.%s(L:%d)";
        String className = caller.getClassName();
        className = className.substring(className.lastIndexOf(".") + 1);
        return String.format(tag, className, caller.getMethodName(), caller.getLineNumber());
    }

    public static void d(String content) {
        if (!BuildConfig.DEBUG) return;
        String tag = generateTag();
        Log.d(tag, content);
    }
    public static void d(String content, Throwable tr) {
        if (!BuildConfig.DEBUG) return;
        String tag = generateTag();
        Log.d(tag, content, tr);
    }

    public static void e(String content) {
        if (!BuildConfig.DEBUG) return;
        String tag = generateTag();
        Log.e(tag, content);
    }
    public static void e(String content, Throwable tr) {
        if (!BuildConfig.DEBUG) return;
        String tag = generateTag();
        Log.e(tag, content, tr);
    }

    public static void i(String content) {
        if (!BuildConfig.DEBUG) return;
        String tag = generateTag();
        Log.i(tag, content);
    }
    public static void i(String content, Throwable tr) {
        if (!BuildConfig.DEBUG) return;
        String tag = generateTag();
        Log.i(tag, content, tr);
    }

    public static void w(String content) {
        if (!BuildConfig.DEBUG) return;
        String tag = generateTag();
        Log.w(tag, content);
    }
    public static void w(String content, Throwable tr) {
        if (!BuildConfig.DEBUG) return;
        String tag = generateTag();
        Log.w(tag, content, tr);
    }

}